/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package thienphuc.patient.bo.impl;

import java.util.List;
import thienphuc.patient.bo.ThuocBO;
import thienphuc.patient.dao.ThuocDAO;
import thienphuc.patient.dao.impl.ThuocDAOImpl;
import thienphuc.patient.dto.NhomThuoc;
import thienphuc.patient.dto.Thuoc;

/**
 *
 * @author QuocDat
 */
public class ThuocBOImpl implements ThuocBO {
    private ThuocDAO thuocDAO;

    public ThuocBOImpl() {
        this.thuocDAO = new ThuocDAOImpl(Thuoc.class);
    }
    
    public List<Thuoc> getAll() throws Exception {
        return this.thuocDAO.findAll();
    }

    public Thuoc getById(int maThuoc) throws Exception {
        return this.thuocDAO.findById(maThuoc);
    }

    public List<Thuoc> getByTenThuoc(String tenThuoc) throws Exception {
        return this.thuocDAO.findByTenThuoc(tenThuoc);
    }

    public List<Thuoc> getByTenThuocAndTrangThai(String tenThuoc, boolean trangThai) throws Exception {
        return this.thuocDAO.findByTenThuocAndTrangThai(tenThuoc, trangThai);
    }

    public List<Thuoc> getByNhomThuoc(NhomThuoc nhomThuoc) throws Exception {
        return this.thuocDAO.findByNhomThuoc(nhomThuoc);
    }

    public List<Thuoc> getByNhomThuocAndTrangThai(NhomThuoc nhomThuoc, boolean trangThai) throws Exception {
        return this.thuocDAO.findByNhomThuocAndTrangThai(nhomThuoc, trangThai);
    }

    public List<Thuoc> getByGiaBan(double giaBanMin, double giaBanMax) throws Exception {
        return this.thuocDAO.findByGiaBan(giaBanMin, giaBanMax);
    }

    public List<Thuoc> getByTrangThai(boolean trangThai) throws Exception {
        return this.thuocDAO.findByTrangThai(trangThai);
    }

    public boolean insertThuoc(Thuoc thuoc) throws Exception {
        return this.thuocDAO.save(thuoc);
    }

    public boolean updateThuoc(Thuoc thuoc) throws Exception {
        return this.thuocDAO.update(thuoc);
    }
}
